<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        var s = new Set();
        var arr = [10,20,30,10,20];
        arr.forEach(x => s.add(x))
        console.log(s) // Set(3) {10,20,30}

        // 数组去重
        var arr2 = [10,20,30,10,20,40];
        var s2 = new Set(arr2);
        console.log([...s2]) // [10,20,30,40]

    </script>
</body>
</html>